<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
   
  <meta name="keywords" content="郑浩枫,周芳怡,咸鱼郑某的博客" />
   
  <meta name="description" content="咸鱼郑某的博客" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    用Python来爬小姐姐 |  岛
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/css/main.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

  

<link rel="alternate" href="/atom.xml" title="岛" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="post-用Python来爬小姐姐" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  用Python来爬小姐姐
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/%E7%94%A8Python%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/" class="article-date">
  <time datetime="2020-03-28T03:51:57.000Z" itemprop="datePublished">2020-03-28</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.2k字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">5分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <p><em>走进Python爬虫</em></p>
<h5 id="1-我们先要知道Python爬虫的原理"><a href="#1-我们先要知道Python爬虫的原理" class="headerlink" title="1.我们先要知道Python爬虫的原理"></a>1.我们先要知道Python爬虫的原理</h5><p>基本的Python爬虫原理很简单，分为三步</p>
<ul>
<li>获取网页源码 </li>
<li>通过分析源码并通过代码来获取其中想要的内容 </li>
<li>进行下载或其他操作<span id="more"></span>
话不多说直接开干</li>
</ul>
<p>先准备上我们的目标网页</p>
<h2 id="开始"><a href="#开始" class="headerlink" title="开始"></a>开始</h2><p>我用的工具是：JetBrains PyCharm 2019.1.1 x64</p>
<p>首先导入几个包</p>
<ul>
<li>import requests</li>
<li>import urllib.request</li>
<li>import re</li>
<li>from bs4 import BeautifulSoup</li>
<li>import os<br><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304000230757.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTM0NjU4,size_16,color_FFFFFF,t_70" alt="导入相应的"><h2 id="遍历所有网页"><a href="#遍历所有网页" class="headerlink" title="遍历所有网页"></a>遍历所有网页</h2>先来看看网页结构<br>分页显示<br><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304114639925.png" alt="在这里插入图片描述">根据观察，除了第一页，其他页后缀都为*.html一共13页<br>所以我们可以通过for遍历所有页码</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs plain">for num in range(13):<br></code></pre></td></tr></table></figure>

<p><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304000912571.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTM0NjU4,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>可以看到我们吧所有页面都便利了一遍<br>但是第一页比较奇葩他没有在浏览器里显示出来，应该是index.html<br>所以我们单独把第一页拎出来<br>最后就是这样：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs plain">for num in range(13):<br>    url &#x3D; &quot;https:&#x2F;&#x2F;www.meitulu.com&#x2F;t&#x2F;loli&#x2F;&quot; + str(num + 1) +  &quot;.html&quot;<br>    if num &#x3D;&#x3D; 0:<br>        url &#x3D; &quot;https:&#x2F;&#x2F;www.meitulu.com&#x2F;t&#x2F;loli&#x2F;&quot; #第一页比较奇葩<br></code></pre></td></tr></table></figure>
<p>接下来就是获取遍历到的每一页的HTML了</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs plain">response &#x3D; requests.get(url)<br>response.encoding&#x3D;&#39;utf-8&#39;<br>html &#x3D; response.text<br>soup &#x3D; BeautifulSoup(html,&quot;html.parser&quot;)<br></code></pre></td></tr></table></figure>
<p>这段主要就是向URL发送GET请求<br>把获取到的HTML代码存放在soup变量里</p>
<h2 id="遍历所有图集"><a href="#遍历所有图集" class="headerlink" title="遍历所有图集"></a>遍历所有图集</h2><p>通过检查元素，我们可以看到每个图集对应的链接：<br><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304001518880.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTM0NjU4,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述">我们先提前初始化好图集链接</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs plain">youngerSister_url &#x3D; []  # 初始化图集链接list<br></code></pre></td></tr></table></figure>

<p>既然是链接，所以我们要获取所有<a>标签中的src,用来进入每个图集</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs plain">a_link &#x3D; soup.find_all(&#39;a&#39;) #所有a标签<br>for link in a_link: #遍历所有链接<br>    u &#x3D; link.get(&quot;href&quot;)<br></code></pre></td></tr></table></figure>
<p>由于一个页面中不止有图集链接，也有其他链接，所以我们要进行筛选</p>
<pre><code>if u != None:
    u2 = re.sub(&quot;\d&quot;,&quot;&quot;,u)  #获取连接类型
    if u2 == &quot;https://www.meitulu.com/item/.html&quot;:
        if not(u in youngerSister_url):
            youngerSister_url.append(u)     #添加进列表
            print(&quot;获取到&quot; + str(len(youngerSister_url)) + &quot;份图集&quot;)
            os.system(&#39;cls&#39;)
</code></pre>
<p>具体原理大概就这样<br>接下来只用把每一页的图集都遍历一遍，并且用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs plain">urllib.request.urlretrieve(p_url, jpg_name) #下载<br></code></pre></td></tr></table></figure>
<p>来下载</p>
<h2 id="结果"><a href="#结果" class="headerlink" title="结果"></a>结果</h2><p>一共获取到将近五万张图片<br><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304002553765.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTM0NjU4,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>最后二次开发做了个网站出来<br><img src="/images/%E7%94%A8pyton%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/20200304003026193.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1OTM0NjU4,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>图片全部来自于互联网<br>我自己的网站就不发出来了，毕竟自己挑出来的精品区才是最好的<br>源码在这：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><code class="hljs plain">import requests<br>import urllib.request<br>import re<br>from bs4 import BeautifulSoup<br>import os<br># 获取文件名<br>file_names &#x3D; os.listdir(&quot;.&#x2F;&quot;) #获取所有文件名<br>#----------------------获取<br>youngerSister_url &#x3D; []  # 初始化女生链接list<br>for num in range(13):<br>    url &#x3D; &quot;https:&#x2F;&#x2F;www.meitulu.com&#x2F;t&#x2F;loli&#x2F;&quot; + str(num + 1) +  &quot;.html&quot;<br>    if num &#x3D;&#x3D; 0:<br>        url &#x3D; &quot;https:&#x2F;&#x2F;www.meitulu.com&#x2F;t&#x2F;loli&#x2F;&quot; #第一页比较奇葩<br>    response &#x3D; requests.get(url)<br>    response.encoding&#x3D;&#39;utf-8&#39;<br>    html &#x3D; response.text<br>    soup &#x3D; BeautifulSoup(html,&quot;html.parser&quot;)<br>    a_link &#x3D; soup.find_all(&#39;a&#39;) #所有a标签<br>    for link in a_link: #遍历所有链接<br>        u &#x3D; link.get(&quot;href&quot;)<br>        if u !&#x3D; None:<br>            u2 &#x3D; re.sub(&quot;\d&quot;,&quot;&quot;,u)  #获取连接类型<br>            if u2 &#x3D;&#x3D; &quot;https:&#x2F;&#x2F;www.meitulu.com&#x2F;item&#x2F;.html&quot;:<br>                if not(u in youngerSister_url):<br>                    youngerSister_url.append(u)     #添加进列表<br>                    print(&quot;获取到&quot; + str(len(youngerSister_url)) + &quot;份图集&quot;)<br>                    os.system(&#39;cls&#39;)<br>print(&quot;共&quot; + str(len(youngerSister_url)) + &quot;个女生图集&quot;)<br>print(&quot;开始下载&quot;)<br>for link in range(len(youngerSister_url)): #进入图集<br>    print(&quot;开始下载第&quot; + str(link + 1) + &quot;份图集&quot;)<br>    # ----------------------获取<br>    url &#x3D; youngerSister_url[link]<br>    response &#x3D; requests.get(url)<br>    response.encoding &#x3D; &#39;utf-8&#39;<br>    html &#x3D; response.text<br>    soup &#x3D; BeautifulSoup(html, &quot;html.parser&quot;)<br>    a_link &#x3D; soup.find_all(&#39;p&#39;)  # 所有a标签<br>    for link in a_link:  # 获取图片数量<br>        p_text &#x3D; link.text<br>        if not p_text.find(&quot;图片数量：&quot;):<br>            print(p_text)<br>            num_start &#x3D; p_text.index(&quot;：&quot;) + 2  # 查找字符串开始位置<br>            num_over &#x3D; p_text.index(&quot;张&quot;) - 1  # 查找字符串结束位置<br>            p_num &#x3D; int(p_text[num_start:num_over])<br>            break  # 结束循环<br>    num_url &#x3D; re.sub(&quot;\D&quot;, &quot;&quot;, url)  # 替换非数字字符<br>    print(&quot;女生编号：&quot; + num_url)<br>    for link in range(p_num):  # 循环图片次数遍<br>        jpg_name  &#x3D; num_url + &quot;_&quot;+ str(link + 1) + &quot;.jpg&quot;  #图片名<br>        if not(jpg_name in file_names): #文件如果存在就跳过<br>            p_url &#x3D; &quot;https:&#x2F;&#x2F;mtl.gzhuibei.com&#x2F;images&#x2F;img&quot; + &quot;&#x2F;&quot; + num_url + &quot;&#x2F;&quot;  + str(link + 1) + &quot;.jpg&quot;<br>            html_head &#x3D; requests.head(p_url)  # 用head方法去请求资源头<br>            re_code &#x3D; html_head.status_code #返回请求值<br>            print(p_url)<br>            print(&quot;进度&quot; + str(link + 1) + &quot;&#x2F;&quot; + str(p_num))<br>            if re_code &#x3D;&#x3D; 200:<br>                urllib.request.urlretrieve(p_url, jpg_name) #下载<br>            else:<br>                print(&quot;该连接无效，跳过！&quot;)<br>    print(&quot;第&quot; + str(link + 1) + &quot;份下载完成！&quot;)<br>input(&quot;全部下载完成，按回车键退出&quot;)<br><br></code></pre></td></tr></table></figure>



      
      <!-- reward -->
      
      <div id="reward-btn">
        打赏
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>版权声明： </strong s>
              本博客所有文章除特别声明外，均采用 <a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="external nofollow"
                target="_blank">Apache License 2.0</a> 许可协议。转载请注明出处！
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://zhfhz.gitee.io/2020/%E7%94%A8Python%E6%9D%A5%E7%88%AC%E5%B0%8F%E5%A7%90%E5%A7%90/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%8A%80%E6%9C%AF/" rel="tag">技术</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%88%AC%E8%99%AB/" rel="tag">爬虫</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/%E5%85%B3%E4%BA%8E%E5%8D%9A%E5%AE%A2/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            关于博客
          
        </div>
      </a>
    
    
      <a href="/2020/%E9%83%A8%E7%BD%B2Hexo/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">部署Hexo</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'QExPaN3yEdYGXDLijnPKdTc8-MdYXbMMI',
        app_key: 'kyQzz6yRJkdRHcMm0tpOvSYY',
        path: window.location.pathname,
        notify: 'true',
        verify: 'false',
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        ZHF
      </li>
      <li>
        
        Powered by
        
        
        <a href="https://hexo.io" target="_blank">Hexo</a> Theme <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src=''></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
    <aside class="sidebar">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="岛"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="https://500px.me/ZHFHZ">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/share.js"></script>


<script src="/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/js/ayer.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>




<script src="/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

    
  </div>
</body>

</html>